<template>
	<view class="panel-step tab-panel">
		<view class="section">
			<view class="hd">[回收设置]</view>
			<view class="bd">
				<view class="item">
					<view class="label">自动回收<=</view>
					<view class="value"><uni-number-box v-model="player.retrieve[0]" color="#abb2bf" background="#21252b" @change="retrieveConfig(0)"/></view>
					<view class="label">级<text>普通</text>装备</view>
				</view>
				<view class="item">
					<view class="label">自动回收<=</view>
					<view class="value"><uni-number-box v-model="player.retrieve[1]" color="#abb2bf" background="#21252b" @change="retrieveConfig(1)"/></view>
					<view class="label">级<text style="color:#0099cc">优秀</text>装备</view>
				</view>
				<view class="item">
					<view class="label">自动回收<=</view>
					<view class="value"><uni-number-box v-model="player.retrieve[2]" color="#abb2bf" background="#21252b" @change="retrieveConfig(2)"/></view>
					<view class="label">级<text style="color:#f0ad4e">史诗</text>装备</view>
				</view>
				<view class="item">
					<view class="label">自动回收<=</view>
					<view class="value"><uni-number-box v-model="player.retrieve[3]" color="#abb2bf" background="#21252b" @change="retrieveConfig(3)"/></view>
					<view class="label">级<text style="color:#dd524d">传说</text>装备</view>
				</view>
			</view>
		</view>
		
		<view class="section">
			<view class="hd">怪物数量</view>
			<view class="bd">
				<view class="item">
					<view class="label">每场战斗刷</view>
					<view class="value"><uni-number-box v-model="player.monster_count"  color="#abb2bf" background="#21252b" :min="4" :max="8" @change="setupMonsterCount"/></view>
					<view class="label">个怪物<text style="color:var(--color-yellow);font-size:12px;margin-left:5px">(8个怪经验1.5倍)</text></view>
				</view>
			</view>
		</view>
		
	</view>
</template>

<script>
	import {
		mapState
	} from "vuex";
	export default {
		name:"panel-setup",
		computed: {
			...mapState(['player']),
		},
		data() {
			return {
				
			};
		},
		methods : {
			retrieveConfig(index){
				
				let retrieve_equip = [];
				
				this.$store.commit('player/commit_retrieve_config',{
					index,
					lv : this.player.retrieve[index]
				});
				

				for(let i=0;i<this.player.bag.length;i++){
					let bag_equip = this.player.bag[i];
					
					for(let j=0;j<4;j++){
						if((bag_equip.qlty - 1) == j && bag_equip.lv <= this.player.retrieve[j]){
							retrieve_equip.push(bag_equip)
						}
					}

				}
				
				if(retrieve_equip.length){
					this.$store.commit('player/commit_retrieve',retrieve_equip)
				}
				
				

			},
			setupMonsterCount(){
				this.$store.commit('player/commit_monster_count',this.player.monster_count)
			}
		}
	}
</script>

<style lang="scss">
	.panel-step{
		padding:20px;
		.section{
			margin-bottom:20px;
			.hd{
				margin-bottom:10px;
				border-bottom: 1px solid #000;
				height:30px;
				color:var(--color-green)
			}
			.bd{
				margin-top:10px;
				.item{
					display:flex;
					align-items: center;
					margin-bottom:10px;
					.value{
						margin:0 10px;
					}
				}
			}
		}
	}
</style>